<?php
$this->breadcrumbs = array(
    'Posts' => array('index'),
    $modelPost->post_id => array('view', 'id' => $modelPost->post_id),
    'Update',
);
?>
<div class="box">
    <header>
        <h5>Update post #<?php echo $modelPost->post_id ?></h5>
    </header>
    <div class="body">
	<?php
	//form for post wish, talent, food, fashion
	if ($icat != 3) {
	    ?>
	    <?php
	    $form = $this->beginWidget('CActiveForm', array(
		'htmlOptions' => array(
		    'class' => 'form-horizontal',
		    'enctype' => "multipart/form-data"
	    )));
	    ?>
	    <?php if ($form->errorSummary($modelPost)) { ?>
		<div class='alert alert-danger'>
		    <?php echo $form->errorSummary($modelPost); ?>
		</div>
	    <?php } ?>
	    <?php if ($success) { ?>
		<div class='alert alert-success'>
		    You have updated successfully.
		</div>
	    <?php } ?>
    	<fieldset>

    	    <legend><span></span><h2 id="portfolioHeading">Edit your post Details</h2></legend>

    	    <div class="control-group">				
    		<label for="inputEmail" class="control-label">Title <span>*</span></label>
    		<div class="controls">
			<?php echo $form->textField($modelPost, 'title'); ?>
    		</div>
    	    </div>

    	    <div class="control-group">
    		<label class="control-label">Content <span>*</span></label>
    		<div class="controls">
			<?php echo $form->textArea($modelPost, 'content'); ?>
    		</div>
    	    </div>

    	    <div class="control-group">
    		<label class="control-label">Photo</label>			    
    		<div class="controls">
			<?php
			if ($aAttachment['photo']) {
			    ?>
			    <div class="pull-left" style="margin-right:20px;">
				<img src="<?php echo SITE_NAME_URL; ?>timthumb.php?src=<?php echo UPLOAD_URL_POST . $aAttachment['photo']; ?>&w=97&h=94" class="photo">
			    </div>
			    <?php
			}
			?>
    		    <input type='file' accept='image/*' name='photo'/>
    		</div>
    	    </div>

    	    <div class="control-group">    			    
    		<label class="control-label">Share link:</label>
    		<div class="controls">

    		    <input type='text' name='sharelink' placeholder="Copy and paste share link from" style="width: 208px" value="<?php
			if (isset($aAttachment['youtube']) && $aAttachment['youtube']) {
			    echo $aAttachment['youtube'];
			} else {
			    if (isset($aAttachment['vimeo']) && $aAttachment['vimeo']) {
				echo $aAttachment['vimeo'];
			    }
			}
			?>"/>
    		    <select name='typeEmbedded'>    				        				    
    			<option value='youtube' <?php
			    if (isset($_POST['typeEmbedded']) && $_POST['typeEmbedded'] == 'youtube')
				echo "selected";
			    else {
				if (isset($aAttachment['youtube']) && $aAttachment['youtube']) {
				    echo "selected";
				}
			    }
			    ?>>Youtube</option>
    			<option value='vimeo' <?php
			    if (isset($_POST['typeEmbedded']) && $_POST['typeEmbedded'] == 'vimeo') {
				echo "selected";
			    } else {
				if (isset($aAttachment['vimeo']) && $aAttachment['vimeo']) {
				    echo "selected";
				}
			    }
			    ?>>Vimeo</option>
    		    </select>
    		</div>
    	    </div>

    	    <div class="control-group">

    		<label for="inputEmail" class="control-label">Publicize, or keep it private</label>

    		<div class="controls">
			<?php echo $form->radioButtonList($modelPost, 'is_private', array('0' => 'Public Page', '1' => 'Private Page')); ?>
    		</div>
    	    </div>

    	    <div class="control-group">
    		<label for="inputEmail" class="control-label">Categories</label>
    		<div class="controls">
			<?php echo $form->dropDownList($modelPost, 'category_id', $aData, array('class' => "select-in-admin")); ?>
    		</div>
    	    </div>

    	</fieldset>
    	<div class="control-group">
    	    <div class="controls">    				
    		<input type="submit" class="btn btn-large btn-info" value="Update" name='submit'/>
    	    </div>
    	</div>

	    <?php
	    $this->endWidget();
	    ?>
	    <?php
	} else {
	    ?>
	    <?php
	    $form = $this->beginWidget('CActiveForm', array(
		'htmlOptions' => array(
		    'class' => 'form-horizontal',
		    'enctype' => "multipart/form-data"
	    )));
	    ?>
	    <?php if ($form->errorSummary($modelPost) || $error) { ?>
		<div class='alert alert-danger'>
		    <?php echo $form->errorSummary($modelPost); ?>
		    <?php echo $error; ?>
		</div>
	    <?php } ?>

	    <?php if ($success) { ?>
		<div class='alert alert-success'>
		    You have updated successfully.
		</div>
	    <?php } ?>
    	<fieldset>
    	    <legend><span></span><h2 id="portfolioHeading">Edit your Event Details</h2></legend>

    	    <div class="control-group">
    		<label for="inputEmail" class="control-label">Your Event Title <span>*</span></label>
    		<div class="controls">
			<?php echo $form->textField($modelPost, 'title', array('class' => 'input-in-admin')); ?>
    		</div>
    	    </div>

    	    <div class="control-group">
    		<label for="inputEmail" class="control-label">Venue Name</label>
    		<div class="controls">
			<?php echo $form->textField($modelPost, 'venue_name_event', array('class' => 'input-in-admin')); ?>
    		</div>
    	    </div>
    	    <div class="control-group">
    		<label for="inputEmail" class="control-label">Street Address</label>
    		<div class="controls">
			<?php echo $form->textField($modelPost, 'street_address_event', array('class' => 'input-in-admin')); ?>
    		</div>
    	    </div>

    	    <div class="control-group">
    		<label for="inputPassword" class="control-label">Date & Time <span>*</span></label>
    		<div class="controls">
			<?php
			$startTimeEvent = date('H:i:s', strtotime($modelPost->time_start_event));
			$startDateEvent = date('Y-m-d', strtotime($modelPost->time_start_event));
			$endTimeEvent = date('H:i:s', strtotime($modelPost->time_end_event));
			$endDateEvent = date('Y-m-d', strtotime($modelPost->time_end_event));
			?>
    		    <div id="datetimepicker4" class="input-append">
    			<input data-format="yyyy-MM-dd" type="text" placeholder="Date" style="width:75px;" name='date_start_event' value="<?php
			    if (isset($_POST['date_start_event']))
				echo $_POST['date_start_event'];
			    else
				echo $startDateEvent;
			    ?>"/>
    			<span class="add-on">
    			    <i data-time-icon="icon-time" data-date-icon="icon-calendar">
    			    </i>
    			</span>
    		    </div>
    		    <div id="datetimepicker3" class="input-append">
    			<input data-format="hh:mm:ss" type="text" placeholder="Time" style="width:60px;" name='time_start_event' value="<?php
			    if (isset($_POST['time_start_event']))
				echo $_POST['time_start_event'];
			    else
				echo $startTimeEvent;
			    ?>"/>
    			<span class="add-on">
    			    <i data-time-icon="icon-time" data-date-icon="icon-calendar">
    			    </i>
    			</span>
    		    </div>
    		    - 

    		    <div id="datetimepicker5" class="input-append">
    			<input data-format="yyyy-MM-dd" type="text" placeholder="Date" style="width:75px;" name='date_end_event' value="<?php
			    if (isset($_POST['date_end_event']))
				echo $_POST['date_end_event'];
			    else
				echo $endDateEvent;
			    ?>">
    			<span class="add-on">
    			    <i data-time-icon="icon-time" data-date-icon="icon-calendar">
    			    </i>
    			</span>
    		    </div>

    		    <div id="datetimepicker6" class="input-append">
    			<input data-format="hh:mm:ss" type="text" placeholder="Time" style="width:60px;" name='time_end_event'value="<?php
			    if (isset($_POST['time_end_event']))
				echo $_POST['time_end_event'];
			    else
				echo $endTimeEvent;
			    ?>">
    			<span class="add-on">
    			    <i data-time-icon="icon-time" data-date-icon="icon-calendar">
    			    </i>
    			</span>
    		    </div>  
    		</div>
    	    </div>
    	    <div class="control-group">
    		<label class="control-label">Photo</label>
    		<div class="controls">
			<?php
			if ($aAttachment['photo']) {
			    ?>
			    <div class="pull-left" style="margin-right:20px;">
				<img src="<?php echo SITE_NAME_URL; ?>timthumb.php?src=<?php echo UPLOAD_URL_POST . $aAttachment['photo']; ?>&w=97&h=94" class="photo">
			    </div>
			    <?php
			}
			?>
    		    <input type='file' accept='image/*' name='photo'/>
    		</div>
    	    </div>

    	    <div class="control-group">
    		<label class="control-label">Share link:</label>
    		<div class="controls">

    		    <input type='text' name='sharelink' placeholder="Copy and paste share link from" style="width: 208px" value="<?php
			if (isset($aAttachment['youtube']) && $aAttachment['youtube']) {
			    echo $aAttachment['youtube'];
			} else {
			    if (isset($aAttachment['vimeo']) && $aAttachment['vimeo']) {
				echo $aAttachment['vimeo'];
			    }
			}
			?>"/>
    		    <select name='typeEmbedded'>    				        				    
    			<option value='youtube' <?php
			    if (isset($_POST['typeEmbedded']) && $_POST['typeEmbedded'] == 'youtube')
				echo "selected";
			    else {
				if (isset($aAttachment['youtube']) && $aAttachment['youtube']) {
				    echo "selected";
				}
			    }
			    ?>>Youtube</option>
    			<option value='vimeo' <?php
			    if (isset($_POST['typeEmbedded']) && $_POST['typeEmbedded'] == 'vimeo') {
				echo "selected";
			    } else {
				if (isset($aAttachment['vimeo']) && $aAttachment['vimeo']) {
				    echo "selected";
				}
			    }
			    ?>>Vimeo</option>
    		    </select>
    		</div>
    	    </div>

    	    <div class="control-group">				
    		<label for="inputEmail" class="control-label">Content <span>*</span></label>
    		<div class="controls">
			<?php echo $form->textArea($modelPost, 'content', array('class' => 'input-in-admin')); ?>
    		</div>
    	    </div>
    	    <div class="control-group">
    		<label for="inputEmail" class="control-label">Organizer Name</label>
    		<div class="controls">
			<?php echo $form->textField($modelPost, 'organizer_name', array('class' => 'input-in-admin')); ?>
    		</div>
    	    </div>
    	    <div class="control-group">
    		<label for="inputEmail" class="control-label">Organizer Description</label>
    		<div class="controls">
			<?php echo $form->textArea($modelPost, 'organizer_description_event', array('class' => 'input-in-admin')); ?>
    		</div>
    	    </div>

    	    <div class="control-group">
    		<label for="inputEmail" class="control-label">Publicize, or keep it private</label>
    		<div class="controls">
			<?php echo $form->radioButtonList($modelPost, 'is_private', array('0' => 'Public Page', '1' => 'Private Page')); ?>
    		</div>
    	    </div>
    	    <div class="control-group">
    		<label for="inputEmail" class="control-label">Categories</label>
    		<div class="controls">
			<?php echo $form->dropDownList($modelPost, 'category_id', $aData, array('class' => 'input-in-admin')); ?>
    		</div>
    	    </div>

    	    <div class="control-group">
    		<label for="inputEmail" class="control-label">Customize Web Address</label>
    		<div class="controls">
			<?php echo $form->textField($modelPost, 'web_addr', array('class' => 'input-in-admin')); ?>    			
    		</div>
    	    </div>
    	</fieldset>

    	<div class="control-group">
    	    <div class="controls">
    		<input type="submit" class="btn btn-large btn-info" value="Update Event" name='submit'/>    			    
    	    </div>
    	</div>

	    <?php $this->endWidget(); ?>
	    <?php
	}
	?>
    </div>
</div>
